package com.kcral.javase.ch.properties;

/**
 * @TODO
 * @Author xu
 * 2025/3/3
 */
public class Personers {
    private String name;
    private int age;
    private boolean gender;
    private Person partner;


    public Personers() {
    }

    public Personers(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.partner = partner;
    }
public void marry(Personers p){
    if (this.partner != null || p.partner != null) {
        System.out.println("不能结婚：某一方已婚。");
        return;
    }
    if (this.gender == p.gender) {
        System.out.println("不能结婚：同性不能结婚。");
        return;
    }
    if ((this.gender && this.age < 24) || (!this.gender && this.age < 22)) {
        System.out.println("不能结婚：未达到结婚年龄。");
        return;
    }
    if ((p.gender && p.age < 24) || (!p.gender && p.age < 22)) {
        System.out.println("不能结婚：未达到结婚年龄。");
        return;
    }

    // 如果满足所有条件，进行结婚

    System.out.println(this.name + " 和 " + p.name + " 恭喜结婚！");
}

    // 获取伴侣的名字


}



